package org.davidliebman.android.awesomecube;


import android.os.Handler;
import android.util.Log;

	/* NOTE:
	 * The array is 3 dimensional. To use the indexes properly
	 * picture a rubik's cube before you. The 0,0,0 position is
	 * in the top left cube element closest to you. X indexes
	 * extend to the _right_. Y indexes extend _down_ and Z indexes
	 * start at the closest cube elements and extend _away_ from you,
	 * or 'back'.
	 */

public class OrientationArray {

	public OpenGLRenderer renderer;
	
	public Mesh mOrientation [][][] = new Mesh[3][3][3];
	public int mTile [][][] = new int[6][3][3];

	public InputQueue mInput = new InputQueue();
	public Handler mHandler;
	
	public static final int MOVE_NONE = 0;
	public static final int MOVE_F_CW = 1;
	public static final int MOVE_F_CCW = 2;
	public static final int MOVE_B_CW = 3;
	public static final int MOVE_B_CCW = 4;
	public static final int MOVE_U_CW = 5;
	public static final int MOVE_U_CCW = 6;
	public static final int MOVE_D_CW = 7;
	public static final int MOVE_D_CCW = 8;
	public static final int MOVE_L_CW = 9;
	public static final int MOVE_L_CCW = 10;
	public static final int MOVE_R_CW = 11;
	public static final int MOVE_R_CCW = 12;
	public static final int MOVE_X_CW = 13;
	public static final int MOVE_X_CCW = 14;
	public static final int MOVE_Y_CW = 15;
	public static final int MOVE_Y_CCW = 16;
	public static final int MOVE_Z_CW = 17;
	public static final int MOVE_Z_CCW = 18;
	public static final int GO_OPTIONS = 19;
	public static final int SHOW_SOLVED = 20;
	public static final int SHOW_SPLASH = 21;
	public static final int SHOW_NOSPLASH = 22;
	
	public OrientationArray() {
		for (int x = 0; x < 3; x ++) {
			for (int y = 0; y < 3; y ++) {
				for (int z = 0; z < 3; z ++ ) {
					mOrientation[x][y][z] = null;
				}
			}
		}
		for (int f = 0; f < 6; f ++) {
			for (int x = 0; x < 3; x ++) {
				for (int y = 0; y < 3; y ++) {
					switch(f) {
					case 0: mTile[f][x][y] = TextureLibrary.YELLOW; break;
					case 1: mTile[f][x][y] = TextureLibrary.WHITE; break;
					case 2: mTile[f][x][y] = TextureLibrary.RED; break;
					case 3: mTile[f][x][y] = TextureLibrary.ORANGE; break;
					case 4: mTile[f][x][y] = TextureLibrary.BLUE; break;
					case 5: mTile[f][x][y] = TextureLibrary.GREEN; break;

					}
					//mTile[f][x][y] = f;
				}
			}
		}
	}
	
	public int getColorFromKey(int f) {
		int mValue = 0;
		switch(f) {
		case 0: mValue = TextureLibrary.YELLOW; break;
		case 1: mValue = TextureLibrary.WHITE; break;
		case 2: mValue = TextureLibrary.RED; break;
		case 3: mValue = TextureLibrary.ORANGE; break;
		case 4: mValue = TextureLibrary.BLUE; break;
		case 5: mValue = TextureLibrary.GREEN; break;

		}
		return mValue;
	}
	
	public void setTiles() {
		for (int f = 0; f < 6; f ++) {
			for (int x = 0; x < 3; x ++) {
				for (int y = 0; y < 3; y ++) {
					if ( true) {
						//all pieces
						switch(f) {
						case 0: mOrientation[x][y][2].setFaces(
								TextureLibrary.NONE,TextureLibrary.NONE,mTile[f][x][y])  ; 
						break;
						case 1: mOrientation[x][y][0].setFaces(
								TextureLibrary.NONE,TextureLibrary.NONE,mTile[f][x][y])  ; 
						break;
						case 2: mOrientation[x][2][y].setFaces(
								TextureLibrary.NONE,mTile[f][x][y], TextureLibrary.NONE)  ;
						break;
						case 3: mOrientation[x][0][y].setFaces(
								TextureLibrary.NONE,mTile[f][x][y],TextureLibrary.NONE)  ;
						break;
						case 4: mOrientation[2][x][y].setFaces(
								mTile[f][x][y],TextureLibrary.NONE,TextureLibrary.NONE)  ;
						break;
						case 5: mOrientation[0][x][y].setFaces(
								mTile[f][x][y],TextureLibrary.NONE,TextureLibrary.NONE)  ;
						break;
						}
						
					}
					
				}
			}
		}
		

	}
	
	public void wipeTiles() {
		
		for (int f = 0; f < 6; f ++) {
			for (int x = 0; x < 3; x ++) {
				for (int y = 0; y < 3; y ++) {
					switch(f) {
					case 0: mTile[f][x][y] = TextureLibrary.YELLOW; break;
					case 1: mTile[f][x][y] = TextureLibrary.WHITE; break;
					case 2: mTile[f][x][y] = TextureLibrary.RED; break;
					case 3: mTile[f][x][y] = TextureLibrary.ORANGE; break;
					case 4: mTile[f][x][y] = TextureLibrary.BLUE; break;
					case 5: mTile[f][x][y] = TextureLibrary.GREEN; break;

					}
					//mTile[f][x][y] = f;
				}
			}
		}
		
	}
	
	
	public void add(Mesh m, int x, int y, int z) {
		mOrientation[x][y][z] = m;
	}
	
	public Mesh get(int x, int y, int z) {
		return mOrientation[x][y][z];
	}
	
	public void setViewingAngle(Positioning mP) {
		for (int x = 0; x < 3; x ++) {
			for (int y = 0; y < 3; y ++) {
				for (int z = 0; z < 3; z ++ ) {
					if(mOrientation[x][y][z] != null) 	{
						mOrientation[x][y][z].mP2 = mP;
					}
				}
			}
		}
	}
	
	public void movePieces() {
		movePieces(renderer);
	}
	
	public void movePieces(OpenGLRenderer mR) {
		int mKey = 0;
		int mStep = MeshList.STEP_15;
		renderer = mR;
		
		//Mesh mTemp [][][] = new Mesh[3][3][3];
		Integer mTileTemp [][][] = new Integer[6][3][3];

		for (int f = 0 ; f < 6; f ++) {
			for (int x = 0; x < 3; x ++ ) {
				for (int y = 0; y < 3; y ++ ) {
					mTileTemp[f][x][y] = TextureLibrary.NONE;
				}
			}
		}
		
		UsedXYZ mXYZ = new UsedXYZ(UsedXYZ.ALL, UsedXYZ.ALL, UsedXYZ.ALL);
		
		//work with queue
		if (mInput.size()> 0) {
			mKey = (Integer)mInput.poll();
		}
		else return;
		
		if (mInput.size() > 1) {
			mStep = MeshList.STEP_90;
		}
		else mStep = MeshList.STEP_15;
		
		int mDirection = MeshList.ANIMATION_INCREASING;
		int mAxis = MeshList.AXIS_X;
		//note: value of 4 means *all* 
		
		if (mKey == MOVE_F_CW ) { //checked
			mXYZ.mX = UsedXYZ.ALL;
			mXYZ.mY = UsedXYZ.ALL;
			mXYZ.mZ = 0;
			mDirection = MeshList.ANIMATION_DECREASING;
			mAxis = MeshList.AXIS_Z;
			
			mTileTemp = this.rotateFAces(mTileTemp, mKey);
			
			//int f = 0;
			for (int i = 0; i < 3; i++) {
		
				//tiles on pieces: ring around front cw
				
				mTileTemp[5][i][0] = mTile[2][i][0];
				mTileTemp[3][i][0] = mTile[5][2-i][0];//
				mTileTemp[4][i][0] = mTile[3][i][0];//
				mTileTemp[2][i][0] = mTile[4][2-i][0];//
					
			}
			
			
		}
		if ( mKey == MOVE_F_CCW) { // checked
			mXYZ.mX = UsedXYZ.ALL;
			mXYZ.mY = UsedXYZ.ALL;
			mXYZ.mZ = 0;
			mDirection = MeshList.ANIMATION_INCREASING;
			mAxis = MeshList.AXIS_Z;
			
			mTileTemp = this.rotateFAces(mTileTemp, mKey);

			for (int i = 0; i < 3; i++) {
		
				//tiles on pieces: ring around front ccw
				
				mTileTemp[2][i][0] = mTile[5][i][0];//
				mTileTemp[5][i][0] = mTile[3][2-i][0];//
				mTileTemp[3][i][0] = mTile[4][i][0];//
				mTileTemp[4][i][0] = mTile[2][2-i][0];//
			}
			 
		}
		if (mKey == MOVE_B_CW ) { // checked
			mXYZ.mX = UsedXYZ.ALL;
			mXYZ.mY = UsedXYZ.ALL;
			mXYZ.mZ = 2;
			mDirection = MeshList.ANIMATION_INCREASING;
			mAxis = MeshList.AXIS_Z;
			//mStep = MeshList.STEP_90;
			
			mTileTemp = this.rotateFAces(mTileTemp, mKey);

			for (int i = 0; i < 3; i++) {
	
				//tiles on pieces: ring around front ccw
				
				mTileTemp[2][i][2] = mTile[5][i][2];//red
				mTileTemp[5][i][2] = mTile[3][2-i][2];//green
				mTileTemp[3][i][2] = mTile[4][i][2];//orange
				mTileTemp[4][i][2] = mTile[2][2-i][2];//blue
			}
			
		}
		if (mKey == MOVE_B_CCW) {//checked
			mXYZ.mX = UsedXYZ.ALL;
			mXYZ.mY = UsedXYZ.ALL;
			mXYZ.mZ = 2;
			mDirection = MeshList.ANIMATION_DECREASING;
			mAxis = MeshList.AXIS_Z;
			//mStep = MeshList.STEP_90;
			
			mTileTemp = this.rotateFAces(mTileTemp, mKey);
			
			for (int i = 0; i < 3; i++) {

				//tiles on pieces: ring around front cw
				
				mTileTemp[5][i][2] = mTile[2][i][2];//green
				mTileTemp[3][i][2] = mTile[5][2-i][2];//orange
				mTileTemp[4][i][2] = mTile[3][i][2];//blue 
				mTileTemp[2][i][2] = mTile[4][2-i][2];//red
				
				
			}
			
		}
		if (mKey == MOVE_L_CW) { // checked 
			mXYZ.mX = 0;
			mXYZ.mY = UsedXYZ.ALL;
			mXYZ.mZ = UsedXYZ.ALL;
			mDirection = MeshList.ANIMATION_INCREASING;
			mAxis = MeshList.AXIS_X;
			
			mTileTemp = this.rotateFAces(mTileTemp, mKey);

			
			for (int i = 0; i < 3; i++) {
				//tiles on pieces: ring around front ccw
				
				mTileTemp[3][0][i] = mTile[0][0][i];//orange
				mTileTemp[1][0][i] = mTile[3][0][2-i];//white
				mTileTemp[2][0][i] = mTile[1][0][i];//red
				mTileTemp[0][0][i] = mTile[2][0][2-i];//yellow
			}
			
			
		}
		if (mKey == MOVE_L_CCW) { // checked
			mXYZ.mX = 0;
			mXYZ.mY = UsedXYZ.ALL;
			mXYZ.mZ = UsedXYZ.ALL;
			mDirection = MeshList.ANIMATION_DECREASING;
			mAxis = MeshList.AXIS_X;
			
			mTileTemp = this.rotateFAces(mTileTemp, mKey);

			
			for (int i = 0; i < 3; i++) {
				mTileTemp[3][0][i] = mTile[1][0][2-i];//
				mTileTemp[1][0][i] = mTile[2][0][i];//
				mTileTemp[2][0][i] = mTile[0][0][2-i];//
				mTileTemp[0][0][i] = mTile[3][0][i];//

			}
			
			
		}
		if (mKey == MOVE_R_CW ) { // checked
			mXYZ.mX = 2;
			mXYZ.mY = UsedXYZ.ALL;
			mXYZ.mZ = UsedXYZ.ALL;
			mDirection = MeshList.ANIMATION_DECREASING;
			mAxis = MeshList.AXIS_X;
			
			mTileTemp = this.rotateFAces(mTileTemp, mKey);

			for (int i = 0; i < 3; i++) {
				mTileTemp[3][2][i] = mTile[1][2][2-i];//
				mTileTemp[1][2][i] = mTile[2][2][i];//
				mTileTemp[2][2][i] = mTile[0][2][2-i];//
				mTileTemp[0][2][i] = mTile[3][2][i];//
			}
			
		}
		if (mKey == MOVE_R_CCW) { // checked
			mXYZ.mX = 2;
			mXYZ.mY = UsedXYZ.ALL;
			mXYZ.mZ = UsedXYZ.ALL;
			mDirection = MeshList.ANIMATION_INCREASING;
			mAxis = MeshList.AXIS_X;
			
			mTileTemp = this.rotateFAces(mTileTemp, mKey);

			for (int i = 0; i < 3; i++) {

				mTileTemp[3][2][i] = mTile[0][2][i];//
				mTileTemp[1][2][i] = mTile[3][2][2-i];//
				mTileTemp[2][2][i] = mTile[1][2][i];//
				mTileTemp[0][2][i] = mTile[2][2][2-i];//
			}
			
			
		}
		if (mKey == MOVE_U_CW ) { // checked
			mXYZ.mX = UsedXYZ.ALL;
			mXYZ.mY = 0;
			mXYZ.mZ = UsedXYZ.ALL;
			mAxis = MeshList.AXIS_Y;
			mDirection = MeshList.ANIMATION_DECREASING;
			
			mTileTemp = this.rotateFAces(mTileTemp, mKey);
			 
			for (int i = 0; i < 3; i++) {

				mTileTemp[1][i][0] = mTile[4][0][i];//
				mTileTemp[4][0][i] = mTile[0][2-i][0];//
				mTileTemp[0][i][0] = mTile[5][0][i];//
				mTileTemp[5][0][i] = mTile[1][2-i][0];//
			}

		}
		if (mKey == MOVE_U_CCW) { // checked
			mXYZ.mX = UsedXYZ.ALL;
			mXYZ.mY = 0;
			mXYZ.mZ = UsedXYZ.ALL;
			mAxis = MeshList.AXIS_Y;
			mDirection = MeshList.ANIMATION_INCREASING;

			mTileTemp = this.rotateFAces(mTileTemp, mKey);
			
			for (int i = 0; i < 3; i++) {
				
				mTileTemp[1][i][0] = mTile[5][0][2-i];//
				mTileTemp[4][0][i] = mTile[1][i][0];//
				mTileTemp[0][i][0] = mTile[4][0][2-i];//
				mTileTemp[5][0][i] = mTile[0][i][0];//
			}

		}
		if (mKey == MOVE_D_CW ) { // checked
			mXYZ.mX = UsedXYZ.ALL;
			mXYZ.mY = 2;
			mXYZ.mZ = UsedXYZ.ALL;
			mAxis = MeshList.AXIS_Y;
			mDirection = MeshList.ANIMATION_INCREASING;

			mTileTemp = this.rotateFAces(mTileTemp, mKey);
			
			for (int i = 0; i < 3; i++) {
				
				mTileTemp[1][i][2] = mTile[5][2][2-i];//
				mTileTemp[4][2][i] = mTile[1][i][2];//
				mTileTemp[0][i][2] = mTile[4][2][2-i];//
				mTileTemp[5][2][i] = mTile[0][i][2];//
			}

		}
		if (mKey == MOVE_D_CCW) {
			mXYZ.mX = UsedXYZ.ALL;
			mXYZ.mY = 2;
			mXYZ.mZ = UsedXYZ.ALL;
			mAxis = MeshList.AXIS_Y;
			mDirection = MeshList.ANIMATION_DECREASING;

			mTileTemp = this.rotateFAces(mTileTemp, mKey);
			
			for (int i = 0; i < 3; i++) {
				
				mTileTemp[1][i][2] = mTile[4][2][i];//
				mTileTemp[4][2][i] = mTile[0][2-i][2];//
				mTileTemp[0][i][2] = mTile[5][2][i];//
				mTileTemp[5][2][i] = mTile[1][2-i][2];//
			}

		}
		
		if (mKey == MOVE_X_CW) { // on R // checked
			mXYZ.mX = UsedXYZ.ALL;
			mXYZ.mY = UsedXYZ.ALL;
			mXYZ.mZ = UsedXYZ.ALL;
			mAxis = MeshList.AXIS_X;
			mDirection = MeshList.ANIMATION_DECREASING;
			
			mTileTemp = this.rotateFAces(mTileTemp, MOVE_R_CW);
			mTileTemp = this.rotateFAces(mTileTemp, MOVE_L_CCW);

			
			for (int j = 0; j < 3; j ++) {
				for (int i = 0; i < 3; i++) {
									
					
					mTileTemp[3][j][i] = mTile[1][j][2-i];//
					mTileTemp[1][j][i] = mTile[2][j][i];//
					mTileTemp[2][j][i] = mTile[0][j][2-i];//
					mTileTemp[0][j][i] = mTile[3][j][i];//
				}
				
			}
		}
		if (mKey == MOVE_X_CCW) { // checked
			mXYZ.mX = UsedXYZ.ALL;
			mXYZ.mY = UsedXYZ.ALL;
			mXYZ.mZ = UsedXYZ.ALL;
			mAxis = MeshList.AXIS_X;
			mDirection = MeshList.ANIMATION_INCREASING;
			
			mTileTemp = this.rotateFAces(mTileTemp, MOVE_R_CCW);
			mTileTemp = this.rotateFAces(mTileTemp, MOVE_L_CW);

			
			for (int j = 0; j < 3; j ++) {
				for (int i = 0; i < 3; i++) {
												
					mTileTemp[3][j][i] = mTile[0][j][i];//
					mTileTemp[1][j][i] = mTile[3][j][2-i];//
					mTileTemp[2][j][i] = mTile[1][j][i];//
					mTileTemp[0][j][i] = mTile[2][j][2-i];//
				}
				
			}
		}
		if (mKey == MOVE_Y_CW) { // on U // checked
			mXYZ.mX = UsedXYZ.ALL;
			mXYZ.mY = UsedXYZ.ALL;
			mXYZ.mZ = UsedXYZ.ALL;
			mAxis = MeshList.AXIS_Y;
			mDirection = MeshList.ANIMATION_DECREASING;
			
			mTileTemp = this.rotateFAces(mTileTemp, MOVE_U_CW);
			mTileTemp = this.rotateFAces(mTileTemp, MOVE_D_CCW);

			
			for (int j = 0; j < 3; j ++) {
				for (int i = 0; i < 3; i++) {
	
					mTileTemp[1][i][j] = mTile[4][j][i];//
					mTileTemp[4][j][i] = mTile[0][2-i][j];//
					mTileTemp[0][i][j] = mTile[5][j][i];//
					mTileTemp[5][j][i] = mTile[1][2-i][j];//
				}
			}
			
		}
		if (mKey == MOVE_Y_CCW) { // checked
			mXYZ.mX = UsedXYZ.ALL;
			mXYZ.mY = UsedXYZ.ALL;
			mXYZ.mZ = UsedXYZ.ALL;
			mAxis = MeshList.AXIS_Y;
			mDirection = MeshList.ANIMATION_INCREASING;
			
			mTileTemp = this.rotateFAces(mTileTemp, MOVE_U_CCW);
			mTileTemp = this.rotateFAces(mTileTemp, MOVE_D_CW);
			
			for (int j = 0; j < 3; j ++) {
				for (int i = 0; i < 3; i++) {
					
					mTileTemp[1][i][j] = mTile[5][j][2-i];//
					mTileTemp[4][j][i] = mTile[1][i][j];//
					mTileTemp[0][i][j] = mTile[4][j][2-i];//
					mTileTemp[5][j][i] = mTile[0][i][j];//
				}
			}
			
		}
		if (mKey == MOVE_Z_CW) { // on F // checked
			mXYZ.mX = UsedXYZ.ALL;
			mXYZ.mY = UsedXYZ.ALL;
			mXYZ.mZ = UsedXYZ.ALL;
			mAxis = MeshList.AXIS_Z;
			mDirection = MeshList.ANIMATION_DECREASING;
			
			mTileTemp = this.rotateFAces(mTileTemp, MOVE_F_CW);
			mTileTemp = this.rotateFAces(mTileTemp, MOVE_B_CCW);

			
			for (int j = 0; j < 3; j ++) {
				for (int i = 0; i < 3; i++) {
									
					//tiles on pieces: ring around front ccw -- 3x
			
					mTileTemp[5][i][j] = mTile[2][i][j];
					mTileTemp[3][i][j] = mTile[5][2-i][j];//
					mTileTemp[4][i][j] = mTile[3][i][j];//
					mTileTemp[2][i][j] = mTile[4][2-i][j];//
				}
				
			}
		}
		if (mKey == MOVE_Z_CCW) {
			mXYZ.mX = UsedXYZ.ALL;
			mXYZ.mY = UsedXYZ.ALL;
			mXYZ.mZ = UsedXYZ.ALL;
			mAxis = MeshList.AXIS_Z;
			mDirection = MeshList.ANIMATION_INCREASING;

			mTileTemp = this.rotateFAces(mTileTemp, MOVE_F_CCW);
			mTileTemp = this.rotateFAces(mTileTemp, MOVE_B_CW);

			
			for (int j = 0; j < 3; j ++) {
				for (int i = 0; i < 3; i++) {
									
					//tiles on pieces: ring around front ccw -- 3x
					mTileTemp[2][i][j] = mTile[5][i][j];//green
					mTileTemp[5][i][j] = mTile[3][2-i][j];//orange
					mTileTemp[3][i][j] = mTile[4][i][j];//blue *
					mTileTemp[4][i][j] = mTile[2][2-i][j];//red
				}
				
			}
		}
	
		
		renderer.startAnimation(mTileTemp, mXYZ, mDirection, mAxis, MeshList.LIMIT_90, mStep);
		
		
	}

	public Integer[][][] rotateFAces( Integer [][][] mTileTemp, int mKey) {
		int j = 0;
		boolean mIncreasing = true;
		switch (mKey) {
		case MOVE_B_CCW : j = 0; mIncreasing = true; break;//
		
		case MOVE_B_CW :  j = 0; mIncreasing = false; break;//
		
		case MOVE_U_CCW : j = 3; mIncreasing = true; break;
		
		case MOVE_U_CW :  j = 3; mIncreasing = false; break;
		
		case MOVE_D_CCW : j = 2; mIncreasing = false; break;
		
		case MOVE_D_CW :  j = 2; mIncreasing = true; break;
		
		case MOVE_F_CCW : j = 1; mIncreasing = false; break;//
		
		case MOVE_F_CW :  j = 1; mIncreasing = true; break;//
		
		case MOVE_L_CCW : j = 5; mIncreasing = false; break;
		
		case MOVE_L_CW :  j = 5; mIncreasing = true; break;
		
		case MOVE_R_CCW : j = 4; mIncreasing = true; break; // true
		
		case MOVE_R_CW :  j = 4; mIncreasing = false; break; // false

		}
		
		if (mIncreasing) {
			for (int i = 0; i < 3; i ++) {
			//tiles on pieces: front cw
				mTileTemp[j][2][i] =   mTile[j][i][0];
				mTileTemp[j][2-i][2] = mTile[j][2][i];
				mTileTemp[j][0][2-i] = mTile[j][2-i][2];
				mTileTemp[j][i][0] =   mTile[j][0][2-i];
			}
		}
		else {
			for (int i = 0; i < 3; i ++) {
			//tiles on pieces: front ccw
				mTileTemp[j][i][0] = mTile[j][2][i];
				mTileTemp[j][2][i] = mTile[j][2-i][2];
				mTileTemp[j][2-i][2] = mTile[j][0][2-i];
				mTileTemp[j][0][2-i] = mTile[j][i][0];
			
			}
		}
		return mTileTemp;
	}
	
	public void finishMovePieces( Integer [][][] mTempTiles) {

		for (int i = 0; i < 3; i ++) {
			for (int j = 0; j < 3; j ++) {
				for (int k = 0; k < 3; k ++ ) {
					
						if (mOrientation[i][j][k] != null) {
							
							mOrientation[i][j][k].mP2 = new Positioning();
							mOrientation[i][j][k].mP4 = new Positioning();
						}
						
				}
			}
		}
		
		for (int f = 0; f < 6; f ++) {
			for (int x = 0; x < 3; x ++) {
				for (int y = 0; y < 3; y ++) {
					if (mTempTiles[f][x][y] != null && mTempTiles[f][x][y] != TextureLibrary.NONE){
						//Log.e("OrientationArray", " copy temp to mTile" + ((f * 6) + (x * 3) + y));
						mTile[f][x][y] = mTempTiles[f][x][y];
					}
				}
			}
		}
		setTiles();
	}
	
	public boolean checkIfSolved() {
		boolean mValue = true;
		boolean mInterupted = false;

		for (int i = 0; i < 6; i ++) {
			int mTester = 0;
			for(int x = 0; x < 3; x ++ ) {
				for (int y = 0; y < 3; y ++ ) {
					if (x == 0 && y == 0) mTester = mTile[i][x][y];
					else if (mTester != mTile[i][x][y]) mInterupted = true;
				}
			}
		}
		if (mInterupted) {
			mValue = !mValue;
		}
		else {
			mHandler.sendEmptyMessage(SHOW_SOLVED);
		}
		
		return mValue;
	}
	
	public void setQueue(InputQueue<Integer> mI) {
		//this.mInput = new InputQueue<Integer> ();
		this.mInput = mI;
	}
	
	public void setRenderer(OpenGLRenderer mR) {
		this.renderer = mR;
	}
	
	public void setHandler(Handler mHandler) {
		this.mHandler = mHandler;
	}
	
	public boolean hasQueueMembers() {
		boolean mValue = false;
		if (mInput.size() > 0) mValue = true;
		else mValue = false;
		return mValue;
		
	}
}

class UsedXYZ {
	
	public int mX;
	public int mY;
	public int mZ;
	
	public static final int ALL = 4;
	
	public UsedXYZ (int x, int y, int z) {
		mX = x;
		mY = y;
		mZ = z;
	}
	
	public UsedXYZ () {
		
	}

	public int getX() {
		return mX;
	}

	public int getY() {
		return mY;
	}

	public int getZ() {
		return mZ;
	}

	public void setX(int mX) {
		this.mX = mX;
	}

	public void setY(int mY) {
		this.mY = mY;
	}

	public void setZ(int mZ) {
		this.mZ = mZ;
	}
	
	
}